﻿namespace EFS.Common.UI.Resources
{
	public static class Caching
	{
		/// <summary>
		/// cache all images
		/// </summary>
		public static void MakeImageSourcesCache()
		{
			// get resources
			System.Reflection.PropertyInfo[] propertyInfoArray = typeof(EFS.Common.UI.Resources.Common).GetProperties(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);

			// load all and cache
			foreach (System.Reflection.PropertyInfo propertyInfo in propertyInfoArray)
			{
				// icon
				if (propertyInfo.PropertyType == typeof(System.Drawing.Icon))
				{
					EFS.Common.UI.Resources.ImageSource.Cache.Add(propertyInfo.GetValue(null, null) as System.Drawing.Icon, propertyInfo.Name);
				}
				else if (propertyInfo.PropertyType  == typeof(System.Drawing.Bitmap))
				{
					EFS.Common.UI.Resources.ImageSource.Cache.Add(propertyInfo.GetValue(null, null) as System.Drawing.Bitmap, propertyInfo.Name);
				}
			}
		}
	}
}
